package 寒假作业.LeetCode;

public class Num26 {
    //删除有序数组中的重复项
    public int removeDuplicates(int[] nums) {
        if(nums.length == 0){
            return 0;
        }
        int n = nums.length;
        int fast = 1;
        int slow = 1;
        while (fast < n){
            if(nums[fast] != nums[fast - 1]){
                nums[slow] = nums[fast];
                ++slow;
            }
            ++fast;
        }
        return slow;
    }
}
